﻿var refreshGirdData; // 更新数据

var companyId = '';
var ztId = '';
var kjnd = '';
var kjqj = '';
var pzrqStart = '';
var pzrqEnd = '';
var userdefault = {};
var alreadyformat = false;
var params = {};

var bootstrap = function ($, learun) {

    var pageWidth = 1024;

    "use strict";
    var page = {
        init: function () {
            userdefault = learun.clientdata.get(['usersetting']);
            //初始化打印插件
            hiprint.init();
            pageWidth = ($('.lr-layout-grid').width());
            page.initGrid();
            page.bind();

        },
        bind: function () {

            $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
                // 调用后台查询
                // queryJson 查询条件
                page.search(queryJson);

            }, 230, 800);
            // 公司选择
            $('#company_select').lrselect({
                type: 'tree',
                // placeholder: '请选择机构',
                height: 300,
                maxHeight: 300,
                // 是否允许搜索
                //allowSearch: true,
                select: function (item) {
                    if (item && item.value != '-1') {
                        companyId = item.value;

                        $('#zt_select').lrselectRefresh({
                            // 访问数据接口地址
                            url: config.base_server() + 'zts/dropdownlist?access_token=' + config.getToken().access_token,
                            // 访问数据接口参数
                            param: {companyId: companyId},
                            select: function (ztItem) {
                                if (!ztItem || ztItem.value == '-1') {
                                    ztId = "";
                                } else {
                                    ztId = ztItem.value;
                                    $("#zt_title").html(ztItem.text);
                                    $('#kjnd_select').lrselectRefresh({
                                        // 访问数据接口地址
                                        url: config.base_server() + 'kjnds/dropdownlist?access_token=' + config.getToken().access_token,
                                        // 访问数据接口参数
                                        param: {companyId: companyId, ztId: ztItem.value},
                                    }).lrselectSet(userdefault.kjnd);
                                }
                            }
                        }).lrselectSet(userdefault.ztId);
                    }
                }
            });
            $('#company_select').lrselectRefresh({
                // 访问数据接口地址
                url: config.base_server() + 'companys/tree?access_token=' + config.getToken().access_token,
                // 访问数据接口参数
                param: {parentId: '0'}
            }).lrselectSet(userdefault.companyId);
            // 帐套选择
            $('#zt_select').lrselect({
                type: 'default',
                //placeholder: '请选择帐套',
                // 展开最大高度
                maxHeight: 300
            });
            // 会计年度选择
            $('#kjnd_select').lrselect({
                type: 'default',
                //placeholder: '请选择会计年度',
                // 展开最大高度
                maxHeight: 300,
                select: function (item) {
                    if (!item || item.value == '-1') {
                        kjnd = '';
                    } else {
                        kjnd = item.value;

                        var beginDate = kjnd + "-01-01";
                        var day = new Date(kjnd, 12, 0);
                        var endDate = kjnd + "-12-" + day.getDate();
                        $("#pzrqStart").val(beginDate);
                        $("#pzrqEnd").val(endDate);

                        page.search();
                    }
                }
            });
            $('#pzrqMonth').lrselect({
                type: 'default',
                // 展开最大高度
                maxHeight: 300,
                placeholder: '月份',
                data: [
                    {'id': '01', 'text': '01'},
                    {'id': '02', 'text': '02'},
                    {'id': '03', 'text': '03'},
                    {'id': '04', 'text': '04'},
                    {'id': '05', 'text': '05'},
                    {'id': '06', 'text': '06'},
                    {'id': '07', 'text': '07'},
                    {'id': '08', 'text': '08'},
                    {'id': '09', 'text': '09'},
                    {'id': '10', 'text': '10'},
                    {'id': '11', 'text': '11'},
                    {'id': '12', 'text': '12'}
                ],
                select: function (item) {
                    if (!item || item.id == '-1') {
                        var beginDate = kjnd + "-01-01";
                        var day = new Date(kjnd, 12, 0);
                        var endDate = kjnd + "-" + 12 + "-" + day.getDate();
                        $("#pzrqStart").val(beginDate);
                        $("#pzrqEnd").val(endDate);
                    } else {
                        var kjqj = item.id;
                        var beginDate = kjnd + "-" + kjqj + "-01";
                        var day = new Date(kjnd, kjqj, 0);
                        var endDate = kjnd + "-" + kjqj + "-" + day.getDate();
                        $("#pzrqStart").val(beginDate);
                        $("#pzrqEnd").val(endDate);
                    }
                }
            });
            // 刷新
            $('#lr_refresh').on('click', function () {
                location.reload();
            });
            // 查询
            $('#btn_Search').on('click', function () {
                page.search(params);
            });
            //打印
            $('#lr_print').on('click', function () {
                var formData = $('.lr-query-formcontent').lrGetFormData();

                var hiprintTemplate = null;
                learun.httpAsyncGet2(config.base_server() + 'printTempletes/findByCode', "&companyId=" + companyId + '&ztId=' + ztId + '&code=srzcb', function (res) {
                    if (res.resp_code == 200) {
                        hiprintTemplate = new hiprint.PrintTemplate({
                            template: JSON.parse(res.data.templete),
                            paginationContainer: '.hiprint-printPagination'
                        });

                        //hiprintTemplate.design('#hiprint-printTemplate');
                        var pzrq = $("#pzrqEnd").val();
                        $.ajax({
                            url: config.base_server() + 'report2s/srzcb?companyId=' + companyId + '&ztId=' + ztId + '&kjnd=' + kjnd + '&pzrqStart=' + params.pzrqStart + '&pzrqEnd=' + params.pzrqEnd + '&isSh=' + params.isSh + '&isJizhang=' + params.isJizhang + '&access_token=' + config.getToken().access_token,
                            type: "post",
                            dataType: "json",
                            success: function (res) {
                                if (res.resp_code == 200) {
                                    var item = {};

                                    item.pzrq = pzrq.substr(0, 4) + "年" + pzrq.substr(5, 2) + "月" + pzrq.substr(8, 10) + "日";
                                    item.ztName = res.data.ztName;
                                    for (var i=0;i<res.data.list.length;i++){
                                        switch (res.data.list[i].kjkmCode){
                                            case "401":
                                                item.k401_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k401_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "402":
                                                item.k402_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k402_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "403":
                                                item.k403_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k403_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "40301":
                                                item.k40301_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k40301_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "40302":
                                                item.k40302_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k40302_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "40303":
                                                item.k40303_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k40303_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "40304":
                                                item.k40304_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k40304_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "40305":
                                                item.k40305_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k40305_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "40306":
                                                item.k40306_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k40306_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "40307":
                                                item.k40307_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k40307_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "404":
                                                item.k404_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k404_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "405":
                                                item.k405_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k405_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "406":
                                                item.k406_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k406_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "407":
                                                item.k407_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k407_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "408":
                                                item.k408_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k408_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "501":
                                                item.k501_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k501_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50101":
                                                item.k50101_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50101_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50102":
                                                item.k50102_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50102_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50103":
                                                item.k50103_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50103_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50104":
                                                item.k50104_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50104_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "502":
                                                item.k502_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k502_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50201":
                                                item.k50201_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50201_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50202":
                                                item.k50202_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50202_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50203":
                                                item.k50203_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50203_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50204":
                                                item.k50204_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50204_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50205":
                                                item.k50205_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50205_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50206":
                                                item.k50206_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50206_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "503":
                                                item.k503_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k503_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50301":
                                                item.k50301_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50301_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50302":
                                                item.k50302_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50302_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50303":
                                                item.k50303_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50303_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50304":
                                                item.k50304_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50304_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50305":
                                                item.k50305_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50305_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "504":
                                                item.k504_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k504_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50401":
                                                item.k50401_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50401_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50402":
                                                item.k50402_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50402_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50403":
                                                item.k50403_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50403_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50404":
                                                item.k50404_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50404_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "505":
                                                item.k505_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k505_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50501":
                                                item.k50501_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50501_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50502":
                                                item.k50502_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50502_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50503":
                                                item.k50503_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50503_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50504":
                                                item.k50504_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50504_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50505":
                                                item.k50505_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50505_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50506":
                                                item.k50506_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50506_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50507":
                                                item.k50507_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50507_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "506":
                                                item.k506_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k506_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50601":
                                                item.k50601_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50601_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50602":
                                                item.k50602_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50602_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50603":
                                                item.k50603_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50603_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50604":
                                                item.k50604_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50604_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50605":
                                                item.k50605_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50605_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50606":
                                                item.k50606_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50606_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "50607":
                                                item.k50607_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k50607_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "507":
                                                item.k507_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k507_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;
                                            case "508":
                                                item.k508_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                                item.k508_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                                break;

                                        }
                                    }

                                    hiprintTemplate.resetPage();

                                    var htmlObj = hiprintTemplate.getHtml(item);
                                    $('.prevViewDiv2').html(htmlObj);

                                    hiprintTemplate.print(item);
                                }
                            }
                        })
                    }
                });
                $('#A4_printByHtml').click(function () {
                    hiprintTemplate.printByHtml($('#myModal .modal-body .prevViewDiv'));
                })
            });

            //导出Excel
            $("#lr_export_excel").on('click', function () {
                if (params.companyId == undefined) {
                    learun.alert.warning('请先查询要导出的数据！');
                    return;
                }
                params.access_token = config.getToken().access_token;

                learun.download({
                    url: config.base_server() + 'report2s/srzcb/excel',
                    param: params
                });
            });
            //导出pdf
            $("#lr_export_pdf").on('click', function () {
                if (params.companyId == undefined) {
                    learun.alert.warning('请先查询要导出的数据！');
                    return;
                }
                params.access_token = config.getToken().access_token;

                learun.download({
                    url: config.base_server() + 'report2s/srzcb/pdf',
                    param: params
                });
            });

        },
        initGrid: function () {

        },
        search: function (param) {
            param = param || {};
            var pzrqStart = $("#pzrqStart").val();
            var pzrqEnd = $("#pzrqEnd").val();
            param.companyId = companyId;
            param.ztId = ztId;
            param.kjnd = kjnd;
            param.pzrqStart = pzrqStart;
            param.pzrqEnd = pzrqEnd;

            var formData = $('.lr-query-formcontent').lrGetFormData();
            param.isSh = formData.isSh;
            param.isJizhang = formData.isJizhang;
            params = param;


            var hiprintTemplate = null;
            learun.httpAsyncGet2(config.base_server() + 'printTempletes/findByCode', "&companyId=" + companyId + '&ztId=' + ztId + '&code=srzcb', function (res) {
                if (res.resp_code == 200) {
                    hiprintTemplate = new hiprint.PrintTemplate({
                        template: JSON.parse(res.data.templete),
                        paginationContainer: '.hiprint-printPagination'
                    });

                    //hiprintTemplate.design('#hiprint-printTemplate');
                    var pzrq = $("#pzrqEnd").val();
                    $.ajax({
                        url: config.base_server() + 'report2s/srzcb?companyId=' + companyId + '&ztId=' + ztId + '&kjnd=' + kjnd + '&pzrqStart=' + param.pzrqStart + '&pzrqEnd=' + param.pzrqEnd + '&isSh=' + param.isSh + '&isJizhang=' + param.isJizhang + '&access_token=' + config.getToken().access_token,
                        type: "post",
                        dataType: "json",
                        success: function (res) {
                            if (res.resp_code == 200) {
                                var item = {};

                                item.pzrq = pzrq.substr(0, 4) + "年" + pzrq.substr(5, 2) + "月" + pzrq.substr(8, 10) + "日";
                                item.ztName = res.data.ztName;
                                for (var i=0;i<res.data.list.length;i++){
                                    switch (res.data.list[i].kjkmCode){
                                        case "401":
                                            item.k401_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k401_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "402":
                                            item.k402_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k402_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "403":
                                            item.k403_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k403_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "40301":
                                            item.k40301_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k40301_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "40302":
                                            item.k40302_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k40302_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "40303":
                                            item.k40303_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k40303_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "40304":
                                            item.k40304_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k40304_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "40305":
                                            item.k40305_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k40305_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "40306":
                                            item.k40306_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k40306_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "40307":
                                            item.k40307_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k40307_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "404":
                                            item.k404_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k404_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "405":
                                            item.k405_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k405_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "406":
                                            item.k406_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k406_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "407":
                                            item.k407_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k407_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "408":
                                            item.k408_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k408_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "501":
                                            item.k501_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k501_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50101":
                                            item.k50101_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50101_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50102":
                                            item.k50102_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50102_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50103":
                                            item.k50103_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50103_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50104":
                                            item.k50104_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50104_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "502":
                                            item.k502_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k502_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50201":
                                            item.k50201_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50201_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50202":
                                            item.k50202_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50202_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50203":
                                            item.k50203_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50203_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50204":
                                            item.k50204_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50204_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50205":
                                            item.k50205_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50205_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50206":
                                            item.k50206_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50206_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "503":
                                            item.k503_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k503_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50301":
                                            item.k50301_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50301_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50302":
                                            item.k50302_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50302_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50303":
                                            item.k50303_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50303_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50304":
                                            item.k50304_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50304_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50305":
                                            item.k50305_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50305_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "504":
                                            item.k504_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k504_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50401":
                                            item.k50401_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50401_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50402":
                                            item.k50402_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50402_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50403":
                                            item.k50403_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50403_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50404":
                                            item.k50404_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50404_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "505":
                                            item.k505_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k505_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50501":
                                            item.k50501_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50501_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50502":
                                            item.k50502_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50502_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50503":
                                            item.k50503_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50503_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50504":
                                            item.k50504_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50504_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50505":
                                            item.k50505_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50505_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50506":
                                            item.k50506_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50506_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50507":
                                            item.k50507_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50507_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "506":
                                            item.k506_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k506_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50601":
                                            item.k50601_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50601_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50602":
                                            item.k50602_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50602_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50603":
                                            item.k50603_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50603_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50604":
                                            item.k50604_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50604_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50605":
                                            item.k50605_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50605_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50606":
                                            item.k50606_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50606_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "50607":
                                            item.k50607_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k50607_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "507":
                                            item.k507_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k507_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;
                                        case "508":
                                            item.k508_byfs = $.formatMoney(res.data.list[i].byfs, 2);
                                            item.k508_bnlj = $.formatMoney(res.data.list[i].bnlj, 2);
                                            break;

                                    }
                                }

                                hiprintTemplate.resetPage();

                                var htmlObj = hiprintTemplate.getHtml(item);
                                $('.prevViewDiv2').html(htmlObj);
                            } else {
                                learun.alert.error(res.resp_msg);
                            }
                        }
                    })
                }
            });
        }
    };

    // 保存数据后回调刷新
    refreshGirdData = function () {
        page.search();
    };

    page.init();
}


